;--------------------------------------------------------------------
;Detecting OF POWER or LOAD STATE
;--------------------------------------------------------------------
detection_init:
	movlw		NO_LAPS			;20 laps (20 cycles*21ms)
	movwf		cnt1			;cnt1 <- NO_LAPS
	clrf		cnt2			;cnt2 <- 0
detection_loop:
	movf		inmasq,W		;number of gpio as parameter
	clrf		GPIO
	andwf		GPIO,W			;check gpio input
	btfss		STATUS,Z		;check if Z is zero
	incf		cnt2,F			;if gpio is high then increment counter cnt2
	call		wait10mst		;delay 10ms	+
	call		wait10mst		;+ delay 10ms +
	call		wait1mst		;+ delay 1ms = 21ms
	decfsz		cnt1,F			;if cnt == 0 then end of loop
	goto		detection_loop	;else continue
	retlw		0
;--------------------------------------------------------------------
;--------------------------------------------------------------------
